Skip to content

Add not operator (!) support to type inference#47

Merged
dak2 merged 1 commit into
mainfrom
add-not-operator-support
Mar 8, 2026
Merged

Add not operator (!) support to type inference#47
dak2 merged 1 commit into
mainfrom
add-not-operator-support

Conversation

@dak2

@dak2 dak2 commented Mar 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add ! operator type inference: ruby-prism represents !expr as a CallNode with method name "!", which previously fell through to the general method dispatch path and produced incorrect type results. Short-circuit the "!" call in process_method_call_common to return TrueClass | FalseClass directly, matching Ruby's actual semantics.
  • Refactor && / || duplicate logic: Extract common union-merge logic from process_and_node and process_or_node into a shared process_binary_logical_op helper.
  • Add Rust unit tests and Ruby integration tests: Cover !true, !!true, !nil, receiver type error detection, and method chaining on ! results.

Test plan

  • cd rust && cargo test --lib — Rust unit tests pass
  • bundle exec rake — Full build + Ruby integration tests pass

🤖 Generated with Claude Code

ruby-prism represents `!expr` as a CallNode with method name "!",
which previously fell through to the general method dispatch path and
produced incorrect type results. This change short-circuits the "!"
call in process_method_call_common to return TrueClass | FalseClass
directly, matching Ruby's actual semantics where `!` always returns
a boolean.

Also refactor process_and_node / process_or_node to share a common
process_binary_logical_op helper, eliminating duplicated union-merge
logic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dak2 dak2 merged commit be5dd3b into main Mar 8, 2026
2 checks passed
@dak2 dak2 deleted the add-not-operator-support branch March 8, 2026 01:49
@dak2 dak2 mentioned this pull request Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant